package com.renwei.yunlong.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.renwei.yunlong.R;
import com.renwei.yunlong.activity.WorkInformationActivity;
import com.zyf.fwms.commonlibrary.utils.AutoUtils;

/**
 * 对象详情  相关 --adapter
 *
 * Created by Administrator on 2017/9/6.
 */

public class NewDetailsRelateAdapter extends RecyclerView.Adapter<NewDetailsRelateAdapter.NewDetailsRelateViewHolder>{

    private LayoutInflater inflater;
    private Context context;
    private String[] title = {"这里是对象名","X86高功率服务器"};

    private NewDetailsRelateOnClickListener onClickListener;

    public NewDetailsRelateAdapter(Context context){
        this.context = context;
        //this.onClickListener = onClickListener;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public NewDetailsRelateViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view =  inflater.inflate(R.layout.item_new_details_relate,null);
        AutoUtils.auto(view);
        return new NewDetailsRelateAdapter.NewDetailsRelateViewHolder(view);
    }

    @Override
    public void onBindViewHolder(NewDetailsRelateViewHolder holder, int position) {
        holder.tvTitleContent.setText(title[position]);
        holder.tvDepartment.setText("安全运维部");
        holder.tvName.setText("顾小弋");
        holder.tvText.setText("包含");
        holder.button.setBackgroundResource(R.drawable.shape_green_card);
        holder.button.setText("正常");
//        holder.itemView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });
    }

    @Override
    public int getItemCount() {
        return title.length;
    }

    public interface NewDetailsRelateOnClickListener{
        void setOnClickListener();
    }

    static class NewDetailsRelateViewHolder extends RecyclerView.ViewHolder{
        private View itemView;
        private TextView tvTitleContent;//标题内容
        private TextView tvDepartment;//部门
        private TextView tvName;//用户名
        private TextView tvText;//文字（包含、正常）
        private Button button;//状态按钮

        public NewDetailsRelateViewHolder(View view) {
            super(view);
            itemView = view;
            tvTitleContent = (TextView) itemView.findViewById(R.id.tv_title_content);
            tvDepartment = (TextView) itemView.findViewById(R.id.tv_department);
            tvName = (TextView) itemView.findViewById(R.id.tv_name);
            tvText = (TextView) itemView.findViewById(R.id.tv_text);
            button = (Button) itemView.findViewById(R.id.button);
        }
    }

}
